<div class="maintop">
    当前位置：发包记录
    <a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($page_current,$page_url)?>" id="btn_refresh" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
</div>
<div class="main-search">
    <table width="100%">

        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="brandsSearch" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    <select name="field">
                        <option value="">全部</option>
                        <option value="uno">玩家号码</option>
                        <option value="issue">红包期号</option>
                    </select>
                    <select name="gameid">
                        <option value="">全部</option>
                        <? foreach($games as $key=>$val){ ?>
                        <option value="<?=$key?>"><?=$val?></option>
                        <? } ?>
                    </select>
                    <select name="state">
                        <option value="">全部</option>
                        <option value="0">待抢</option>
                        <option value="1">完成</option>
                        <option value="2">超时</option>
                    </select>
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    &nbsp;日期：从
                    <input id="fromTime" name="fromTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['fromTime']?date('Y-m-d',intval(strtotime($searchdata['fromTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;至
                    <input id="toTime" name="toTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['toTime']?date('Y-m-d',intval(strtotime($searchdata['toTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;&nbsp;
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input type="submit" value="搜索" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg">
            <th>No.</th>
            <th>发包玩家</th>
            <th>期号</th>
            <th>玩法名称</th>
            <th>已抢 / 人数</th>
            <th>红包金额</th>
            <th>发包时间</th>
            <th>门票</th>
            <th>抽水</th>
            <th>概率</th>
            <th title="正常玩家数 / 概率玩家数 / 机器人数">普 / 概 / 机</th>
            <th title="当（正常玩家数≤1 AND 概率玩家≤1 AND 内部玩家≥）时的随机概率状态（0->不启用，1->启用）">随机</th>
            <th title="指定庄家赢的随机值">庄赢</th>
            <th>结束时间</th>
            <th width="40">状态</th>
        </tr>
        <?
        $page_coin = 0;
        $page_ticket = 0;
        $page_winerprofit = 0;
        foreach($datas as $v){
            $page_coin += floatval($v['coin']);
            $page_ticket += floatval($v['ticket']);
            $page_winerprofit += floatval($v['winerprofit']);
            ?>
            <tr>
                <td><?=$v['id']?></td>
                <td style="text-align:left">
                    <? if($this->deep_in_array($v['uid'], 'uid', $this->autosenduserlist)){ ?>
                        <i class="trygame">机</i>
                    <? } ?>
                    <a href="/members/members_list_edit?uid=<?=$v['uid']?>" title="编辑 - <?=$v['nickname']?>" class="colorbox"><?=$v['uno']?>【<?=$v['nickname']?>】</a>
                </td>
                <td>
                    <? //if($v['state']==1){ ?>
                        <a href="/members/betslog_grablist?issue=<?=$v['issue']?>&gamename=<?=$games[$v['gameid']]?>" target="ajax" func="loadpage"><?=$v['issue']?></a>
                    <? //}else{ ?>
                        <?//=$v['issue']?>
                    <? //} ?>
                </td>
                <td><?=$games[$v['gameid']]?>
                    <?php

                    if(empty($v['usertype'])) echo '<i class="trygame">试</i>';
                    if(!empty($v['pass'])) echo '<i class="mastpass">令</i>';

                    ?></td>
                <td><?=$v['cur'] ?> / <?=$v['need'] ?></td>
                <td style="text-align:right"><?=number_format($v['coin'],2,'.','') ?></td>
                <td><?=$this->formatTimes($v['begintimes'])?></td>
                <td style="text-align:right"><?=($v['ticket']>0 ? $v['ticket'] : '-')?></td>
                <td style="text-align:right"><?=($v['winerprofit']>0 ? $v['winerprofit'] : '-')?></td>
                <td><?=($v['psw'] ? '<font color=red>开</font>' : '-')?></td>
                <td><?=($v['play'] ? $v['play'] : '-')?> / <?=($v['pret'] ? $v['pret'] : '-')?> / <?=($v['inside'] ? $v['inside'] : '-')?></td>
                <td><?=$v['rint']?></td>
                <td><?=($v['bankerwon'] ? '<font color=red>稳</font>' : '-')?></td>
                <td><?=(empty($v['endtimes']) ? '--' : $this->formatTimes($v['endtimes']))?></td>
                <td>
                    <?
                    switch($v['state']){
                        case 1:
                        case 2:
                            echo $this->redState[$v['state']];
                            break;
                        case 0:
                            if($v['cur']>=$v['need']) { ?>
                                <a href="/members/gameover?issue=<?=$v['issue']?>&state=1" target="ajax" func="loadpage">结算</a>
                            <? }else{ ?>
                                <a href="/members/gameover?issue=<?=$v['issue']?>&state=2" target="ajax" func="loadpage">退回</a>
                            <? }
                    }?>
                </td>
            </tr>
        <? } ?>
        <tr>
            <td colspan="5">本页合计</td>
            <td><?=$this->formatCoin($page_coin) ?></td>
            <td></td>
            <td><?=$this->formatCoin($page_ticket) ?></td>
            <td><?=$this->formatCoin($page_winerprofit) ?></td>
            <td colspan="7"></td>
        </tr>
        <tr>
            <td colspan="5">合计</td>
            <td></td>
            <td></td>
            <td><?=$this->formatCoin($total['ticket']) ?></td>
            <td><?=$this->formatCoin($total['winerprofit']) ?></td>
            <td colspan="7"></td>
        </tr>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){
        var _key = this.sKey.value;
        if(_key.length<=0){
            //throw '搜索关键字不能为空';
        }
    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        if(!empty($searchdata['fromTime'])){
            echo '$("input[name=fromTime]").val("'.$searchdata['fromTime'].'");';
        }
        if(!empty($searchdata['toTime'])){
            echo '$("input[name=toTime]").val("'.$searchdata['toTime'].'");';
        }
        if(''!=$searchdata['state']){
            echo '$("select[name=\'state\'] option[value=\''.$searchdata['state'].'\']").attr("selected", "selected");';
        }
        if(''!=$searchdata['gameid']){
            echo '$("select[name=\'gameid\'] option[value=\''.$searchdata['gameid'].'\']").attr("selected", "selected");';
        }
        if(!empty($searchdata['field'])){
            echo '$("select[name=\'field\'] option[value=\''.$searchdata['field'].'\']").attr("selected", "selected");';
        }
        ?>
        $(".colorbox").colorbox({ iframe: true,width:"80%",height:"80%" });
        /*
        clearInterval(refreshTimeObj);
        refreshTimeObj = setInterval(function(){
            $("#btn_refresh").trigger("click");
        },10000);
        */
    });
</script>
